package com.zhaorujie.rpc.core.route.impl;

import com.zhaorujie.rpc.core.route.RpcLoadBalance;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.List;
import java.util.Random;

/**
 * @author 赵汝杰
 * @version v1.0
 * @description RpcLoadBalanceRandomStrategy
 * @date 2024/3/11
 **/
public class RpcLoadBalanceRandomStrategy implements RpcLoadBalance {

    private static final Logger logger = LoggerFactory.getLogger(RpcLoadBalanceRandomStrategy.class);

    private Random random = new Random();

    @Override
    public String route(String serviceKey, List<String> addressList) {
        int count = random.nextInt(addressList.size());
        return addressList.get(count);
    }
}
